import jsonp from 'common/js/jsonp'
import {
  CommendParam,
  CommendOptions
} from './config'
// 请求歌手页 - 列表
export function getSingerList() {
  let url = 'https://u.y.qq.com/cgi-bin/musicu.fcg'
  let obj = {
    'comm': {
      'ct': 24,
      'cv': 10000
    },
    'singerList': {
      'module': 'Music.SingerListServer',
      'method': 'get_singer_list',
      'param': {
        'area': -100,
        'sex': -100,
        'genre': -100,
        'index': -100,
        'sin': 0,
        'cur_page': 1
      }
    }
  }
  const data = Object.assign({}, CommendParam, {
    g_tk: 1238936754,
    callback: 'recom123',
    loginUin: 0,
    hostUin: 0,
    platform: 'yqq',
    needNewCode: 0,
    key: 'all_all_all',
    data: JSON.stringify(obj)
  })
  let DisListOptions = Object.assign({}, {
    // 前缀
    // prefix: 'recom',
    // 回调名称
    name: 'recom123'
  }, CommendOptions)
  return jsonp(url, data, DisListOptions)
}

export function getSingerList2() {
  const url = 'https://c.y.qq.com/v8/fcg-bin/v8.fcg'

  const data = Object.assign({}, CommendParam, {
    channel: 'singer',
    page: 'list',
    key: 'all_all_all',
    pagesize: 100,
    pagenum: 1,
    hostUin: 0,
    needNewCode: 0,
    platform: 'yqq'
  })

  return jsonp(url, data, CommendOptions)
}

export function getSingerDetail(mid) {
  const url = 'https://c.y.qq.com/v8/fcg-bin/fcg_v8_singer_track_cp.fcg'

  const data = Object.assign({}, CommendParam, {
    begin: 0,
    num: 30,
    songstatus: 1,
    hostUin: 0,
    needNewCode: 0,
    platform: 'yqq',
    singermid: mid,
    order: 'listen'
  })

  return jsonp(url, data, CommendOptions)
}

// 获取歌曲
export function getSong(songmid) {
  let url = 'https://u.y.qq.com/cgi-bin/musicu.fcg'
  let obj = {
    'req_0': {
      'module': 'vkey.GetVkeyServer',
      'method': 'CgiGetVkey',
      'param': {
        'guid': '984503204',
        'songmid': [songmid],
        'songtype': [0],
        'uin': '1647090769',
        'loginflag': 1,
        'platform': '20'
      }
    },
    'comm': {
      'uin': 1647090769,
      'format': 'json',
      'ct': 20,
      'cv': 0
    }
  }

  const data = Object.assign({}, CommendParam, {
    g_tk: 1369717059,
    callback: 'recom123',
    loginUin: 0,
    hostUin: 0,
    platform: 'yqq',
    needNewCode: 0,
    data: JSON.stringify(obj)
  })
  let DisListOptions = Object.assign({}, {
    // 前缀
    // prefix: 'recom',
    // 回调名称
    name: 'recom123'
  }, CommendOptions)
  return jsonp(url, data, DisListOptions)
}
